package cz.muni.fi.pa165.sportclubmanager.dto;

import cz.muni.fi.pa165.sportclubmanager.entity.Team;

/**
 *
 * @author Michal Prokeš, 72758
 */
public class TeamDTOMapping {
    /**
     * Map TeamDTO to Team entity
     * @param dto TeamDTO object
     * @return Team entity
     */
     public static Team toEntity(TeamDTO dto) {
        if(dto==null) { return null; }
        
        Team entity = new Team();
        
        entity.setId(dto.getId());
        entity.setAgeCategory(AgeCategoryDTOMapping.toEntity(dto.getAgeCategory()));
        entity.setName(dto.getName());
        
        return entity;
    }
      
     /**
     * Map Team to TeamDTO with all attributes
     * @param entity Team entity
     * @return TeamDTO with all attributes
     */
     public static TeamDTO toDto(Team entity) {
        if(entity==null) { return null; }
        
        TeamDTO dto = new TeamDTO();
        
        dto.setId(entity.getId());
        dto.setAgeCategory(AgeCategoryDTOMapping.toDto(entity.getAgeCategory()));
        dto.setName(entity.getName());
        
        return dto;
    }
   
    
}
